namespace KTOP.Homeworks.Hw5.Logics
{
    public struct Link
    {
        private readonly int _x;
        private readonly int _y;

        public Link(int x, int y)
        {
            _x = x;
            _y = y;
        }

        public int X
        {
            get { return _x; }
        }

        public int Y
        {
            get { return _y; }
        }

        #region Equality

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (obj.GetType() != typeof (Link)) return false;
         
            return Equals((Link) obj);
        }
        public bool Equals(Link other)
        {
            return other._x == _x && other._y == _y;
        }
        public override int GetHashCode()
        {
            unchecked
            {
                return (_x*397) ^ _y;
            }
        }

        #endregion

        public override string ToString()
        {
            return string.Format("{0}-{1}", _x + 1, _y + 1);
        }
    }
}